#include "pic16e_reg.h"

regexManager* regexManager::instance = new regexManager();
DebugUtils* DebugUtils::instance = new DebugUtils();


int regexManager :: assignRegex(int x){
    if (findRegix(x) != -1) return -2; 
    int i = 7;
    int idx = -1;
    while (i--) {if (!regexs[i]) idx = i;};
    if (idx != -1){
        std::cout << "assign to " << idx << "value is" << (int)x << std::endl;
        regexs[idx] = x;
    }
    return idx;
}

int regexManager :: findRegix(int x){
    int i = 7;
    while (i--) {if (regexs[i] == x) return i;}
    return -1;
}

int regexManager :: unAssignRegex(int x){
    int idx = findRegix(x);
    if (idx != -1){
        std::cout << "unAssign to " << idx << "value is" << (int)x << std::endl;
        regexs[idx] = 0;
    }
    return idx;
}


class DebugUtils;